package com.zone.module_base.viewmodel

import android.util.Log
import androidx.databinding.ObservableArrayList
import com.zone.core.base.BaseViewModel
import com.zone.core.ext.toJson
import com.zone.module_base.model.TestModel

/**
 *Author: last
 *Time: 2024/7/1
 *Description: 框架功能测试
 */
class TestActivityVM(val str:String) : BaseViewModel() {
    val TAG = "TestActivityVM"

    val items = ObservableArrayList<TestModel>()

    init {
        items.add(TestModel(0, "功能测试", true))
        items.add(TestModel(1, "下载测试"))
        items.add(TestModel(2, "热修复Tinke"))
        items.add(TestModel(3, "图片加载"))
        items.add(TestModel(4, "权限申请测试"))
        items.add(TestModel(5, "数据库测试"))
        items.add(TestModel(6, "文件操作"))
        items.add(TestModel(7, "webView测试"))
        items.add(TestModel(8, "播放器"))
        items.add(TestModel(9, "投屏协议测试"))
        items.add(TestModel(10, "其他测试"))

        Log.d(TAG, "===================: " + str)
        postEvent(6)
    }

    fun onItemClick(item: TestModel) {
        val oldItem = items.first { it.isSelect }
        items[items.indexOf(oldItem)] = oldItem.apply { isSelect = false }
        item.isSelect = true
        items[items.indexOf(item)] = item
        postEvent(item.position)
    }
}